import os
from datetime import datetime
import pytz

def current_date_str():
    return datetime.now(pytz.timezone("Asia/Shanghai")).strftime("%Y-%m-%d")

def save_raw_articles(data, folder='raw_articles'):
    os.makedirs(folder, exist_ok=True)
    for idx, item in enumerate(data):
        filename = os.path.join(folder, f"{current_date_str()}_{idx}.txt")
        with open(filename, 'w', encoding='utf-8') as f:
            f.write(item["title"] + "\n\n" + item["content"]) 